#
#	Makefile for dcmjpeg/apps
#

@SET_MAKE@

SHELL = /bin/sh
VPATH = @srcdir@:@top_srcdir@/include:@top_srcdir@/@configdir@/include
srcdir = @srcdir@
top_srcdir = @top_srcdir@
configdir = @top_srcdir@/@configdir@

include $(configdir)/@common_makefile@


ofstddir =$(top_srcdir)/../ofstd
ofstdinc = -I$(ofstddir)/include
ofstdlibdir = -L$(ofstddir)/libsrc
ofstdlib = -lofstd

oflogdir = $(top_srcdir)/../oflog
ofloginc = -I$(oflogdir)/include
ofloglibdir = -L$(oflogdir)/libsrc
ofloglib = -loflog

dcmdatadir = $(top_srcdir)/../dcmdata
dcmdatainc = -I$(dcmdatadir)/include
dcmdatalibdir = -L$(dcmdatadir)/libsrc
dcmdatalib = -ldcmdata

dcmimgledir = $(top_srcdir)/../dcmimgle
dcmimgleinc = -I$(dcmimgledir)/include
dcmimglelibdir = -L$(dcmimgledir)/libsrc
dcmimglelib = -ldcmimgle

dcmimagedir = $(top_srcdir)/../dcmimage
dcmimageinc = -I$(dcmimagedir)/include
dcmimagelibdir = -L$(dcmimagedir)/libsrc
dcmimagelib = -ldcmimage

dcmjpegdir = $(top_srcdir)/../dcmjpeg
dcmjpeginc = -I$(dcmjpegdir)/include
dcmjpeglibdir = -L$(dcmjpegdir)/libsrc -L$(dcmjpegdir)/libijg8 -L$(dcmjpegdir)/libijg12 \
	-L$(dcmjpegdir)/libijg16
dcmjpeglib = -ldcmjpeg -lijg8 -lijg12 -lijg16

LOCALINCLUDES = $(dcmjpeginc) $(ofstdinc) $(ofloginc) $(dcmdatainc) $(dcmimageinc) \
	$(dcmimgleinc)
LIBDIRS = -L$(top_srcdir)/libsrc $(dcmjpeglibdir) $(dcmimagelibdir) $(dcmimglelibdir) \
	$(dcmdatalibdir) $(ofloglibdir) $(ofstdlibdir)
LOCALLIBS = $(dcmjpeglib) $(dcmimagelib) $(dcmimglelib) $(dcmdatalib) $(ofloglib) \
	$(ofstdlib) $(TIFFLIBS) $(PNGLIBS) $(ZLIBLIBS) $(CHARCONVLIBS) $(MATHLIBS)

objs = dcmdjpeg.o dcmcjpeg.o dcmj2pnm.o dcmmkdir.o
progs = dcmdjpeg dcmcjpeg dcmj2pnm dcmmkdir


all: $(progs)

dcmdjpeg: dcmdjpeg.o
	$(CXX) $(CXXFLAGS) $(LIBDIRS) $(LDFLAGS) -o $@ $@.o $(LOCALLIBS) $(LIBS)

dcmcjpeg: dcmcjpeg.o
	$(CXX) $(CXXFLAGS) $(LIBDIRS) $(LDFLAGS) -o $@ $@.o $(LOCALLIBS) $(LIBS)

dcmj2pnm: dcmj2pnm.o
	$(CXX) $(CXXFLAGS) $(LIBDIRS) $(LDFLAGS) -o $@ $@.o $(LOCALLIBS) $(LIBS)

dcmmkdir: dcmmkdir.o
	$(CXX) $(CXXFLAGS) $(LIBDIRS) $(LDFLAGS) -o $@ $@.o $(LOCALLIBS) $(LIBS)


install: all
	$(configdir)/mkinstalldirs $(DESTDIR)$(bindir)
	for prog in $(progs); do \
		$(INSTALL_PROGRAM) $$prog$(BINEXT) $(DESTDIR)$(bindir) && $(STRIP) $(DESTDIR)$(bindir)/$$prog$(BINEXT) ;\
	done


clean:
	rm -f $(objs) $(progs) $(TRASH)

distclean:
	rm -f $(objs) $(progs) $(DISTTRASH)


dependencies:
	$(CXX) -MM $(defines) $(includes) $(CPPFLAGS) $(CXXFLAGS) *.cc  > $(DEP)

include $(DEP)
